import React, { Fragment, PureComponent } from 'react';
import { Redirect } from 'react-router-dom';
import { connect } from 'react-redux';


class Write extends PureComponent {
    render() {
        const { loginStatus } = this.props;
        // 如果登了就显示写文章
        if (loginStatus) {
            return (
                <Fragment>
                    <div>写文章页面</div>
                </Fragment>
            )
        }
        // 如果没登录就跳转到登录页面
        else {
            return <Redirect to='/login' />
        }
    }
};

const mapState = (state) => ({
    loginStatus: state.getIn(['login','login'])
})

export default connect(mapState,null)(Write);